<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>首页</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />

<!-- easyui -->
<script type="text/javascript" th:src="@{/easyui/jquery.min.js}" ></script>
<script type="text/javascript" th:src="@{/easyui/jquery.easyui.min.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/default/easyui.css}">
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/icon.css}">
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/color.css}">
	<script type="text/javascript" th:src="@{/easyui/locale/easyui-lang-zh_CN.js}"></script>
	<style>
		*{
			text-align: center;
		}
		h2,#addForm{
			padding: 10px 20px;
		}
		#addForm>*{
			margin-top: 10px;
		}
		#addForm input{
			margin-left: 10px;
		}
	</style>
</head>
<body>
	<h2>易耗品入库登记</h2>
	<form id="addForm" method="post">
		编号:<input name="cid" type="number" class="easyui-validatebox" data-options="required:true"/><br>
		名称:<input name="cname" class="easyui-validatebox" data-options="required:true"/><br>
		单位:<input name="util" class="easyui-validatebox"/><br>
		规格:<input name="attributes" class="easyui-validatebox" /><br>
		单价:<input name="price" class="easyui-validatebox"/><br>
		备注:<input name="info" class="easyui-validatebox"/><br>
		库存:<input name="inventory" class="easyui-validatebox" type="number" data-options="required:true"/><br>
		<a id="saveBtn" href="#" class="easyui-linkbutton">增加</a>
	</form>
	<script type="text/javascript" th:inline="none">
	$(function(){
		/*保存*/
		$("#saveBtn").click(function () {
			$("#addForm").form("submit",{
				url:"/consumable/saveConsumable",     //提交表单
				onSubmit:function(){
					return $("#editForm").form("validate");
				},
				success:function(data){   //回传数据
					data=eval("("+data+")")
					if(data.success){
						$("#win").window("close");
						$("#list").datagrid("reload");
						$.messager.alert("提示","保存成功!","info");
					}else{
						$.messager.alert("提示","保存失败！",data.msg,"error");
					}
				}
			});
		})

	});
	</script>

</body>